home *** CD-ROM | disk | FTP | other *** search
- ;void delete_right_plus(strg,border);
- ; unsigned char *strg,border;
-
- EXTRN _memory_model:byte
- EXTRN _error_code:byte
-
- _TEXT SEGMENT BYTE PUBLIC 'CODE'
- ASSUME CS:_TEXT
- PUBLIC _delete_right_plus
- _delete_right_plus proc near
- push bp ;
- mov bp,sp ;set up stack frame
- push di ;
- push si ;
- pushf ;
- cmp _memory_model,0 ;near or far?
- jle begin ;jump if near
- inc bp ;else add 2 to BP
- inc bp ;
- begin: cmp _memory_model,2 ;data near or far?
- jb L0 ;jump if near
- les di,dword ptr [bp+4] ;load string address
- jmp short L00 ;jump ahead
- L0: mov ax,ds ;ES = DS
- mov es,ax ;
- mov di,[bp+4] ;string address
- L00: mov _error_code,1 ;1 = null string
- cmp byte ptr es:[di],0 ;null?
- je L3 ;quit if so
- cld ;direction forward
- mov al,0 ;seek terminator
- mov cx,0FFH ;max characters
- repne scasb ;go find it
- dec di ;back to end of string
- mov cx,di ;figure max chars to search
- sub cx,si ;
- dec di ;to last char of string
- mov al,[bp+6] ;get border char
- std ;direction reverse
- inc _error_code ;2 = border char not found
- repne scasb ;go find border char
- jnz L3 ;quit if not found
- mov byte ptr es:[di+1],0 ;set terminating byte
- mov _error_code,0 ;0 = success
- L3: popf ;
- pop si ;
- pop di ;
- pop bp ;
- cmp _memory_model,0 ;quit
- jle quit ;
- db 0CBh ;RET far
- quit: ret ;RET near
- _delete_right_plus ENDP
- _TEXT ENDS
- END